#include "render/Camera.h"
#include <glm/gtc/matrix_transform.hpp>

glm::mat4 Camera::view() const {
    float cx = target.x + distance * cosf(pitch) * cosf(yaw);
    float cy = target.y + distance * sinf(pitch);
    float cz = target.z + distance * cosf(pitch) * sinf(yaw);
    glm::vec3 pos(cx,cy,cz);
    return glm::lookAt(pos,target,glm::vec3(0,1,0));
}

glm::mat4 Camera::proj(float aspect) const {
    return glm::perspective(glm::radians(60.0f), aspect, 0.1f, 100.0f);
}

glm::vec3 Camera::position() const {
    float cx = target.x + distance * cosf(pitch) * cosf(yaw);
    float cy = target.y + distance * sinf(pitch);
    float cz = target.z + distance * cosf(pitch) * sinf(yaw);
    return glm::vec3(cx,cy,cz);
}